/**
 * @author Tobias Boehm
 *
 * 14.04.2011
 */
package org.anddev.andengine.extension.tbsengine.team;

import java.util.HashMap;
import java.util.HashSet;

import org.anddev.andengine.extension.tbsengine.player.BasePlayer;
import org.anddev.andengine.extension.tbsengine.shared.IImageOrTextSelectableItem;

import android.graphics.drawable.Drawable;


/**
 * This class represents a Team of {@link BasePlayer}s.
 * 
 * @author Tobias Boehm
 *
 */
public class Team extends HashSet<BasePlayer> implements IImageOrTextSelectableItem, Comparable<Team>  {

	protected final int mTeamID;
		
	public Team(final int pTeamID){
		
		this.mTeamID = pTeamID;
	}
	
	public int getTeamID(){
		
		return this.mTeamID;
	}
	
	@Override
	public boolean equals(Object object) {
		
		if(object instanceof Team){
			
			return (this.getTeamID() == ((Team)object).getTeamID());
				
		}else{
		
			return super.equals(object);
		}
	}
	
	@Override
	public String toString() {
		
		return this.getTeamID()+"";
	}

	@Override
	public Drawable getIcon() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getName() {
		
		return this.mTeamID+"";
	}
	
	public static HashMap<Integer,Team> generateTeamsMap(final int pTeamCount){
		
		final HashMap<Integer,Team> teams = new HashMap<Integer,Team>();
		
		for(int i = 0; i < pTeamCount; i++){
			
			final int teamId = i + 1;
			
			teams.put(teamId, new Team(teamId));
		}
		
		return teams;
	}

	@Override
	public int compareTo(Team another) {
		
		if(this.mTeamID < another.getTeamID()){
			
			return -1;
			
		}else if(this.mTeamID == another.getTeamID()){
			
			return 0;
		}else{
		
			return 1;
		}
	}
}
